import request from '@/utils/request'
import { BASE_URL } from '@/api/config.js'

// 任务发布分页查询

export function getfillinTask(params) {
  return request({
    method: 'get',
    url: '/fillin/fillinTask/page',
    params
  })
}

// 填报记录查询
export function getfillinRecords(params) {
  return request({
    method: 'get',
    url: '/fillin/fillinRecords/page',
    params
  })
}

// 任务发布

export function postPublish(data) {
  return request({
    method: 'post',
    url: '/fillin/fillinTask/publish',
    data: data
  })
}

// 获取任务模板

export function getInfo(params) {
  return request({
    method: 'get',
    url: '/fillin/template/getInfo',
    params
  })
}

// 业主单位下拉框
export function getSelect(params) {
  return request({
    method: 'get',
    url: '/fillin/fillinUnit/select',
    params
  })
}

// 项目下拉框选项
export function getProjectSelect(params) {
  return request({
    method: 'get',
    url: '/fillin/fillinProject/select',
    params
  })
}

// 填报保存
export function postSave(data) {
  return request({
    method: 'post',
    url: '/fillin/fillinRecords/save',
    data: data
  })
}

// 下载统计表
export function downExport(params) {
  return request({
    method: 'get',
    responseType: 'blob',
    url: '/fillin/fillinRecords/export',
    params
  })
}

// 获取填报详情
export function postfillinTask(data) {
  return request({
    method: 'post',
    url: `fillin/fillinTask/get?pkid=${data}`
  })
}

// 最新填报信息
export function lastStatistics() {
  return request({
    method: 'get',
    url: 'fillin//fillinTask/lastStatistics'
  })
}

// 日期下拉框
export function groupByDate() {
  return request({
    method: 'get',
    url: '/fillin//fillinTask/groupByDate'
  })
}
// 批量删除任务
export function fillinDeleteByIds(params) {
  return request({
    method: 'get',
    url: '/fillin/fillinTask/deleteByIds',
    params
  })
}
// 项目名单分页查询
export function fillinProjectQuery(params) {
  return request({
    method: 'get',
    url: '/fillin/fillinProject/pageList',
    params
  })
}
// 添加项目
export function addProject(data) {
  return request({
    method: 'post',
    url: '/fillin/fillinProject/addProject',
    headers: {
      'Content-Type': 'application/json'
    },
    data: data
  })
}
// 更新项目
export function updateProject(data) {
  return request({
    method: 'post',
    url: '/fillin/fillinProject/updateProject',
    data: data
  })
}
// 删除项目
export function deleteProject(params) {
  return request({
    method: 'delete',
    url: '/fillin/fillinProject/deleteProject',
    params: params
  })
}
// 项目类型查询
export function projectTypeQuery(params) {
  return request({
    method: 'get',
    url: '/fillin/fillinProjectType/queryList',
    params: params
  })
}
// 项目名单通知更新
export function fillinProjectUpdate(params) {
  return request({
    method: 'get',
    url: '/fillin/fillinProject/update',
    params
  })
}
// 项目名单删除
export function fillinProjectDelete(params) {
  return request({
    method: 'get',
    url: '/fillin/fillinProject/delete',
    params
  })
}
// 项目名单导入
export function fillinProjectImport(data) {
  return request({
    method: 'post',
    url: '/fillin/fillinProject/ImportExcel',
    data: data
  })
}
// 项目名单导出
export function fillinProjectExport() {
  return request({
    method: 'post',
    responseType: 'blob',
    url: '/fillin/fillinProject/exportExcel'
  })
}

// 新增项目通知
export function noticeAdd(data) {
  return request({
    method: 'post',
    url: '/fillin/notice/add',
    data: data
  })
}

// 新增项目发布
export function noticePublish(data) {
  return request({
    method: 'post',
    url: '/fillin/notice/publish',
    data: data
  })
}

// 项目通知更新
export function noticeUpdate(data, pkid) {
  return request({
    method: 'put',
    url: `/fillin/notice/update/${pkid}`,
    data: data
  })
}

// 项目通知删除
export function noticeDelete(pkid) {
  return request({
    method: 'delete',
    url: `/fillin/notice/delete?pkid=${pkid}`
  })
}

// 项目通知查询
export function noticeQuery(params) {
  return request({
    method: 'get',
    url: '/fillin/notice/query/page',
    params
  })
}

// 项目通知详情查询
export function noticeQueryOne(pkid) {
  return request({
    method: 'get',
    url: `/fillin/notice/query?pkid=${pkid}`
  })
}

// 项目通知统计
export function noticeQueryTotal() {
  return request({
    method: 'get',
    url: '/fillin/notice/queryTotal'
  })
}
// 通知未读
export function noticeQueryUnRead() {
  return request({
    method: 'get',
    url: '/fillin/notice/queryUnRead'
  })
}

// 附件上传
export function noticeFileUpload(data, onUploadProgress) {
  return request({
    method: 'post',
    url: '/resource/file/upload/file',
    data: data,
    onUploadProgress: onUploadProgress || null
  })
}

// 附件下载
export function noticeFileDownload(pkid) {
  return request({
    method: 'get',
    responseType: 'blob',
    url: `/resource/file/download?pkid=${pkid}`,
    timeout: 0
  })
}

// 附件删除
export function noticeFileDelete(fileId) {
  return request({
    method: 'delete',
    url: `/fillin/notice/delete/file?fileId=${fileId}`
  })
}

// 附件新增
export function noticeFileAdd(data) {
  return request({
    method: 'post',
    url: '/fillin/notice/add/file',
    data: data
  })
}

// 新增推送用户
export function noticeUserAdd(data) {
  return request({
    method: 'post',
    url: '/fillin/notice/user/add',
    data: data
  })
}
// 删除推送用户
export function noticeUserDelete(pkid) {
  return request({
    method: 'delete',
    url: `/fillin/notice/user/delete?pkid=${pkid}`
  })
}
// 修改推送用户
export function noticeUserUpdate(data, pkid) {
  return request({
    method: 'put',
    url: `/fillin/notice/user/update/${pkid}`,
    data: data
  })
}
// 查询通知对象列表
export function noticeUserQuery(params) {
  return request({
    method: 'get',
    url: '/fillin/notice/user/query',
    params
  })
}
// 用户阅读填报
export function noticeUserRead(data) {
  return request({
    method: 'post',
    url: '/fillin/notice/read/fillin',
    data: data
  })
}
// 用户导入
export function noticeUserUpload(data) {
  return request({
    method: 'post',
    url: '/fillin/notice/user/import',
    data: data
  })
}
// 用户导出
export function noticeUserDown() {
  return request({
    method: 'get',
    responseType: 'blob',
    url: '/fillin/notice/user/export'
  })
}
// 用户名称校验
export function noticeUserCheck(params) {
  return request({
    method: 'get',
    url: '/fillin/notice/user/judgeName',
    params
  })
}

// 安全管理下拉框查询
export function securityType(params) {
  return request({
    method: 'get',
    url: `/fillin/security/query/type/${params}`
  })
}
// 安全管理查询
export function securityQuery(params) {
  return request({
    method: 'get',
    url: '/fillin/security/query',
    params
  })
}
// 安全管理新增
export function securityAdd(data) {
  return request({
    method: 'post',
    url: '/fillin/security/add',
    data: data
  })
}
// 安全管理更新
export function securityUpdate(data) {
  return request({
    method: 'put',
    url: '/fillin/security/edit',
    data: data
  })
}
// 安全管理删除
export function securityDelete(pkid) {
  return request({
    method: 'delete',
    url: `/fillin/security/delete?pkid=${pkid}`
  })
}
// 附件上传
export function securityFileUpload(data) {
  return request({
    method: 'post',
    url: '/resource/file/upload/file',
    data: data
  })
}

// 附件下载
export function securityFileDownload(pkid) {
  return request({
    method: 'get',
    responseType: 'blob',
    url: `/resource/file/download?pkid=${pkid}`
  })
}
// 获取附件链接
export function securityFileUrl(pkid) {
  return `${
    process.env.NODE_ENV === 'production'
      ? BASE_URL
      : // window.location.origin + '/future/data'
        '/api'
  }/resource/file/download?pkid=${pkid}`
}
// 附件删除
export function securityFileDelete(fileId) {
  return request({
    method: 'delete',
    url: `/fillin/security/delete/file?fileId=${fileId}`
  })
}

// 附件新增
export function securityFileAdd(data) {
  return request({
    method: 'post',
    url: '/fillin/security/add/file',
    data: data
  })
}

// 报告分页查询
export function securityQueryPage(params) {
  return request({
    method: 'get',
    url: '/fillin/security/queryList',
    params
  })
}
// 问题汇总表查询
export function securityQueryAllProblem(params) {
  return request({
    method: 'get',
    url: '/fillin/security/queryAllByProjectId',
    params
  })
}
// 问题提交
export function securitySubmit(params) {
  return request({
    method: 'get',
    url: '/fillin/security/changeStatus',
    params
  })
}
// 安全报告统计
export function securityQueryTotal() {
  return request({
    method: 'get',
    url: '/fillin/security/querySecurityTotal'
  })
}
// 复查报告下拉框
export function securityQueryCheckList() {
  return request({
    method: 'get',
    url: '/fillin/security/queryCheckList'
  })
}
// 检测报告下拉框
export function securityQueryProjectName() {
  return request({
    method: 'get',
    url: '/fillin/securityProject/queryProjectName'
  })
}
// 工程概况查询
export function securityProjectQuery(params) {
  return request({
    method: 'get',
    url: '/fillin/securityProject/query',
    params
  })
}
// 工程概况新增
export function securityProjectAdd(data) {
  return request({
    method: 'post',
    url: '/fillin/securityProject/add',
    data: data
  })
}
// 工程概况编辑
export function securityProjectEdit(data) {
  return request({
    method: 'post',
    url: '/fillin/securityProject/edit',
    data: data
  })
}
// 报告保存或编辑
export function securitySaveOrUpdate(data) {
  return request({
    method: 'post',
    url: '/fillin/security/saveOrUpdate',
    data: data
  })
}

// 删除安全报告
export function deleteReport(pkid) {
  return request({
    method: 'delete',
    url: `/fillin/security/deleteBaseInfo?pkid=${pkid}`
  })
}
